<?php 
$user=$session->read('User');
$companyid=$session->read("companyid");
$isflag=$action->checkPermissions($user,$companyid);
?>
<div class="right_side_operate_area">
	<div class="right_side_title left">
    	<h2>
		<?php 
		$companyname=$session->read("companyname");
		echo $html->link($companyname,"/companys/showinfosummary/".$companyid);
		?>
    	</h2>
    	<div class='clear'></div>
    </div>
    <div class="right item_add_btn">
		<?php 
			if($form->value('DevelopmentCost.id')){
			$str_title=__("Edit",true);
			}else{
			$str_title=__("Add",true);
			}
    		echo $html->link(__("Cancel",true).$str_title,"/companys/depcosts/");
    	?>
	</div>
    <div class="clear"></div>
</div>
<?php
echo $form->create('Company', array('url' => "/companys/editdepcost",'id'=>'patentform','enctype'=>'multipart/form-data','onsubmit'=>"return checkdinfo()"));
?>
<div class="right_side_scollbar">
<div class="detail_info_panel">
<div class="details_item_line">
	<div class="details_item">
	    <div class="form_left_title left"><font style="color:red">*</font><?php echo "时间" ;?>：</div>
	    <?php if($form->value('DevelopmentCost.c_time')){ ?>
	    <div class="form_right_e_input form_date_picker left"><?php echo $form->text('DevelopmentCost.c_time',array("maxlength"=>"10","style"=>"width:130px","value"=> date("Y-m-d",strtotime($form->value('DevelopmentCost.c_time'))),"onfocus"=>"WdatePicker()"));?></div>
	    <?php }else{ ?>
	    <div class="form_right_e_input form_date_picker left"><?php echo $form->text('DevelopmentCost.c_time',array("maxlength"=>"10","onfocus"=>"WdatePicker()","style"=>"width:130px"));?></div>
	    <?php } ?>
	    <div id='costtimemessage' style='display:none;' class="error_message">请选择时间</div>
	</div>
</div>
<div class="details_item_line">
	<div class="details_item">
	    <div class="form_left_title left"><font style="color:red">*</font><?php echo "总额" ;?>：</div>
	    <div class="form_right_e_input left">
	    <?php echo $form->text('DevelopmentCost.cost',array("placeholder"=>"0.00","onkeydown"=>"checkpricekeyup(this,event)","style"=>"width:80px"));?> ￥
	    </div>
	    <div id='costmessage' style='display:none;' class="error_message">请填写费用</div>
	</div>
	<div class="details_item">
	    <div class="form_left_title left"><?php echo "占总营额比重" ;?>：</div>
	    <div class="form_right_e_input left">
	    <?php echo $form->text('DevelopmentCost.cost_percent',array("placeholder"=>"0.00","onkeydown"=>"checkpricekeyup(this,event)","style"=>"width:80px"));?> %
	    </div>	    
	</div>
</div>
<div class="details_item_line">
	<div class="details_item">
	    <div class="form_left_title left"><?php echo "研究与实验" ;?>：</div>
	    <div class="form_right_e_input left">
	    <?php echo $form->text('DevelopmentCost.research_exp',array("placeholder"=>"0.00","onkeydown"=>"checkpricekeyup(this,event)","style"=>"width:80px"));?> ￥ 
	    </div>	    
	</div>
	<div class="details_item">
	    <div class="form_left_title left"><?php echo "新产品费用" ;?>：</div>
	    <div class="form_right_e_input left">
	    <?php echo $form->text('DevelopmentCost.new_product',array("placeholder"=>"0.00","onkeydown"=>"checkpricekeyup(this,event)","style"=>"width:80px"));?> ￥ 
	    </div>	  
	</div>
</div>
<div class="details_item_line">
	<div class="details_item">
	    <div class="form_left_title left"><?php echo "政府拨款" ;?>：</div>
	    <div class="form_right_e_input left">
	    <?php echo $form->text('DevelopmentCost.govern_funding',array("placeholder"=>"0.00","onkeydown"=>"checkpricekeyup(this,event)","style"=>"width:80px"));?> ￥ 
	    </div>	    
	</div>
	<div class="details_item">
	    <div class="form_left_title left"><?php echo "企业自筹费用" ;?>：</div>
	    <div class="form_right_e_input left">
	    <?php echo $form->text('DevelopmentCost.raised_enterprise',array("placeholder"=>"0.00","onkeydown"=>"checkpricekeyup(this,event)","style"=>"width:80px"));?> ￥ 
	    </div>	    
	</div>
</div>
<div class="details_item_line">
	<div class="details_item">
	    <div class="form_left_title left"><?php echo "备注" ;?>：</div>
	    <div class="form_right_e_input left"><?php echo $form->textarea('DevelopmentCost.remark');?></div>	    
	</div>
</div>
<div class="details_item_line">
	<div class="details_item">
	    <div class="form_left_title left"><?php echo "附件";?>：</div>
	    <div class="form_right_input left">
     	<?php if($attachments){?>
        	<div class="file_category_list">
        		<div id="filelist0" class="file_lists">
        			<ul>
	                	<?php
	                	$dan="'";
	                	foreach($attachments as $attachment) {
								echo "<li>";
								echo "<span>".$html->link($attachment["file_name"],'/projects/download/'.$attachment["id"],null)."</span>";
								echo "<span class='source_upload_date'>".date("Y-m-d",strtotime($attachment["created"]))."</span>";
								//if($isflag){
									echo '<span class="source_upload_delete"><a title="删除" onclick="delfile(this,'.$dan.$attachment["id"].$dan.',0)" href="javascript:void(0)"></a></span>';
								//}
								echo "</li>";
						}
	                	?>
	                </ul>
                </div>
            </div>
	    <?php }?>
	    <div id="add1" class="left text_box"> 
			<div class="file_add_box">
				<input type="file" id="upload[]" name="upload[]" />
			</div>
		</div>
		<div class="clear"></div>
		<div id="add2" class="left filelist"></div>
		<div class="left clear">
			<div class="left add_sub_file_btn">
				<span onclick="add()" href="#"><?php echo $html->image('list-add.png')?></span>&nbsp;
				<span onclick="remove()" href="#"><?php echo $html->image('list-remove.png')?></span>
			</div>
		</div>
	 </div>
	</div>
</div>
<?php 
echo $form->hidden('DevelopmentCost.owner',array('value' => $user['id'])) ;
echo $form->hidden('DevelopmentCost.cid',array('value' => $companyid)) ;
echo $form->hidden('DevelopmentCost.id') ;
?>
<div class="details_item_line">
	<div class="details_item">
	    <div class="form_left_title left"></div>
		<div class="form_add_submit left">
	   		 <?php echo $form->submit(__('Save',true), array("id"=>"adduser","name"=>"submit","class"=>"buttom","div"=>false));  ?>
	    </div>
	</div>
</div>
</div>
</div>
<?php echo $this->element('delfileconfirm',array("title"=>"删除提示","message"=>"你确定要删除吗？")) ?>
<script>
if(!$("#DevelopmentCostId").val()){
$(document).ready(function() {	
  $("#uniform-DevelopmentCostCostType0").children().addClass("checked");
  });
  }
function checkdinfo(){
	 if($("#DevelopmentCostCTime").val().trim() == ''){
			$("#costtimemessage").css('display','block');
			return false;
	  }else{
		 	 $("#costtimemessage").css('display','none');
		  }
		  
	  if($("#DevelopmentCostCost").val().trim() == ''){
			$("#costmessage").css('display','block');
			return false;
	  }else{
		 	 $("#costmessage").css('display','none');
		  }		  	   
}
</script>